﻿using System;
using System.Windows.Forms;

namespace Marmat.Forms
{
    internal partial class ErrorForm : Form
    {
        public ErrorForm(Exception ex)
        {

            // 此调用是设计器所必需的。
            this.InitializeComponent();

            // 在 InitializeComponent() 调用之后添加任何初始化。
            this.Exception = ex;
            Button1.Name = "Button1";
            CheckBox1.Name = "CheckBox1";
        }

        private Exception Exception;

        /// <summary>
    /// 显示错误信息
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    /// <remarks></remarks>
        private void ErrorForm_Load(object sender, EventArgs e)
        {
            this.BMemoBox1.Value = this.Exception.Message;
        }

        /// <summary>
    /// 切换错误信息的显示模式
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    /// <remarks></remarks>
        private void CheckBox1_CheckedChanged(object sender, EventArgs e)
        {
            if (this.CheckBox1.Checked == true)
            {
                this.BMemoBox1.Value = this.Exception.ToString();
            }
            else
            {
                this.BMemoBox1.Value = this.Exception.Message;
            }
        }


        /// <summary>
    /// 复制错误信息到剪切板
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    /// <remarks></remarks>
        private void Button1_Click(object sender, EventArgs e)
        {
            Clipboard.SetText(this.Exception.ToString());
        }


        // ''' <summary>
        // ''' 发送错误信息到服务端
        // ''' </summary>
        // ''' <param name="sender"></param>
        // ''' <param name="e"></param>
        // ''' <remarks></remarks>
        // Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        // Dim Send As New BI.Client.SendException
        // Dim boo As Boolean = Send.SendException(My.Application.Info.AssemblyName, My.Application.Info.Version, ex)
        // If boo = False Then
        // System.Windows.Forms.MessageBox.Show("发送失败！")
        // End If
        // End Sub
    }
}